package com.mk.web.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.mk.web.model.CUser;
import com.mk.web.service.CUserService;
import com.mk.web.service.impl.CUserServiceImpl;

/**
 * Created by WangChen on 2018/11/26 20:16.
 */
@WebServlet("/user")
public class CUserServlet extends HttpServlet{

    CUserService userService = new CUserServiceImpl();
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String name = req.getParameter("name");
        CUser user = userService.findByName(name);
        System.out.println(user);

        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8;");
        resp.getWriter().write(user.toString());

    }
}
